﻿@using Lari.Configuration
@model Lari.Services.ViewModel.ConsultantSpecializationModel
@helper HiddenAllDepartmentSpecialization()
    {
        for (int i = 0; i < Model.DepartmentSpecialization.Count; i++)
        {
            @Html.HiddenFor(m => m.DepartmentSpecialization[i].Key)
            @Html.HiddenFor(m => m.DepartmentSpecialization[i].Value)
        }
}
@helper HiddenConsultantSpecialization()
    {
        if (Model.ConsultantSpecialization != null)
        {
            for (int i = 0; i < Model.ConsultantSpecialization.Count; i++)
            {
                @Html.HiddenFor(m => m.ConsultantSpecialization[i].Key)
                @Html.HiddenFor(m => m.ConsultantSpecialization[i].Value)
                @Html.HiddenFor(m => m.ConsultantSpecialization[i].IsSelected)

            }
        }
    
}
@helper HiddenRemainingSpecialization()
    {
        if (Model.RemainingDepartmentSpecialization != null)
        {
            for (int i = 0; i < Model.RemainingDepartmentSpecialization.Count; i++)
            {
                @Html.HiddenFor(m => m.RemainingDepartmentSpecialization[i].Key)
                @Html.HiddenFor(m => m.RemainingDepartmentSpecialization[i].Value)
                @Html.HiddenFor(m => m.RemainingDepartmentSpecialization[i].IsSelected)

            }
        }
    
}
<div id="pagetitle">
    <h1>@ScreenName.Users.ManageConsultantSpecialization</h1>
</div>
<div class="spacer">
</div>
<div id="pagecontent">
    <div class="tab">
        Employee Details</div>
    <div class="tabContent">
        @Html.Partial("_EmployeeView", Model.Employee)
    </div>
    @if (Model.Employee.IsConsultant)
    {
        if (Model.DepartmentSpecialization == null || Model.DepartmentSpecialization.Count <= 0)
        {
        <div class="spacer">
        </div>  
        @Html.Partial("_DisplyMessaage", MessageCode.User.SpecializationNotDefinedForDepartment)
        }
        else
        {
        <div class="spacer">
        </div>
        <div style="padding-left: 150px; padding-right: 150px;">
            <table width="100%">
                <tr>
                    <td width="45%">
                        <fieldset>
                            <legend>Available Specialization</legend>
                            @if (Model.RemainingDepartmentSpecialization != null && Model.RemainingDepartmentSpecialization.Count > 0)
                            {
                                using (Html.BeginForm(ActionConst.Users.AddConsultantSpecialization, ControllerConst.Users, FormMethod.Post))
                                {
                                @Html.AntiForgeryToken("AddConsulSpeci")
                                <table class="webgrid">
                                    <thead>
                                        <tr class="webgrid-header">
                                            <th>
                                                Select
                                            </th>
                                            <th>
                                                Specialization
                                            </th>
                                        </tr>
                                    </thead>
                                    @HiddenConsultantSpecialization()
                                    @HiddenAllDepartmentSpecialization()
                                    @Html.HiddenFor(m => m.Employee.ID)
                                    @for (int i = 0; i < Model.RemainingDepartmentSpecialization.Count; i++)
                                    {
                                        <tr class="@(i % 2 == 0 ? "webgrid-row-style" : "webgrid-alternating-row")">
                                            <td>
                                                @Html.CheckBoxFor(m => m.RemainingDepartmentSpecialization[i].IsSelected)
                                            </td>
                                            <td>
                                                @Model.RemainingDepartmentSpecialization[i].Value
                                                @Html.HiddenFor(m => m.RemainingDepartmentSpecialization[i].Key)
                                                @Html.HiddenFor(m => m.RemainingDepartmentSpecialization[i].Value)
                                            </td>
                                        </tr>
                                    }
                                    <tr>
                                        <td colspan="2">
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2" align="right">
                                            <input type="submit" value="Add >>" id="btnLink" />
                                        </td>
                                    </tr>
                                </table>
                                }

                            }
                            else
                            {
                                @Html.Partial("_DisplyMessaage", "All specialization are linked")
                            }
                        </fieldset>
                    </td>
                    <td width="10%">
                        &nbsp;
                    </td>
                    <td width="45%">
                        <fieldset>
                            <legend>Consultant Specialization</legend>
                            @if (Model.ConsultantSpecialization != null && Model.ConsultantSpecialization.Count > 0)
                            {
                                using (Html.BeginForm(ActionConst.Users.RemoveConsultantSpecialization, ControllerConst.Users, FormMethod.Post))
                                {
                                @Html.AntiForgeryToken("removeConsulSpeci")
                                <table class="webgrid">
                                    <thead>
                                        <tr class="webgrid-header">
                                            <th>
                                                Select
                                            </th>
                                            <th>
                                                Specialization
                                            </th>
                                        </tr>
                                    </thead>
                                    @HiddenAllDepartmentSpecialization()
                                    @HiddenRemainingSpecialization()
                                    @Html.HiddenFor(m => m.Employee.ID)
                                    @for (int i = 0; i < Model.ConsultantSpecialization.Count; i++)
                                    {
                                        <tr class="@(i % 2 == 0 ? "webgrid-row-style" : "webgrid-alternating-row")">
                                            <td>
                                                @Html.CheckBoxFor(m => m.ConsultantSpecialization[i].IsSelected)
                                            </td>
                                            <td>
                                                @Model.ConsultantSpecialization[i].Value
                                                @Html.HiddenFor(m => m.ConsultantSpecialization[i].Key)
                                                @Html.HiddenFor(m => m.ConsultantSpecialization[i].Value)
                                            </td>
                                        </tr>
                                    }
                                    <tr>
                                        <td colspan="2">
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2" align="left">
                                            <input type="submit" value="<< Remove" id="btnRemove" />
                                        </td>
                                    </tr>
                                </table>
                                }


                            }
                            else
                            {
                                @Html.Partial("_DisplyMessaage", MessageCode.User.SpecializationNotDefinedForConsultant)
                            }
                        </fieldset>
                    </td>
                </tr>
            </table>
        </div>
            
        }
	   
    }
    else
    {
        <div class="spacer">
        </div>  
        @Html.Partial("_DisplyMessaage", MessageCode.User.EmployeeIsNotConsultant)
		 
    }
    <div class="doubleSpacer">
    </div>
    <div>@Html.ActionLink("Back to Employee Details", ActionConst.Users.ViewEmployee, new { id = Model.Employee.ID })</div>
    <div class="spacer">
    </div>
</div>
<script type="text/javascript">

    $(document).ready(function () {
        $("#btnLink").button();
        $("#btnRemove").button(); 
        
    });
</script>
